{% extends "base.html" %}

{% block extra_head %}
{% endblock %}

{% block mid %}
  {% if content_html %}
    {{ content_html }}
  {% else %}
    <p>There is no content here.
      <a id="create" class="action">Select something</a> to create?
      </p>
    <div id="ct_builder"></div>
    <script>
    $('h1.title > a > span');

    $('#create').one('click', function() {
      $('#ct_builder').css('display', 'none');

      // .load will remove the script tags in this case
      $('#ct_builder').load('/content_types/ #mid', null, function() {
        $('#ct_builder').show('slow');
        $('#ct_builder .smenu_item').click(function() {
          var url = '/content_types/' + this.id + '?editor=true';
          $.get(url, function(data) {
            $('#ct_builder .sviewer').html(data);
            $('#ct_builder .smenu').hide('slow', function () {
                $('#ct_builder .sviewer').show('slow');
                });
            });
          });
        });

      // Add click handling back to create
      $('#create').click(function() {
        $('#ct_builder .sviewer').hide('slow', function() {
            $('#ct_builder .smenu').show('slow');
            });
        });
      });
    </script>
  {% endif %}
{% endblock %}
